<?php
/**
 * OperationLog.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-02-18 19:45:47
 * @modified    2023-02-18 19:45:47
 *
 */

namespace App\Models;

use Carbon\Carbon;

class OperationLog extends BaseModel
{
    protected $table = 'operation_log';

    protected $fillable = [
        'business_id',
        'business_type',
        'business_body'
    ];

    protected $appends = [
        'create_time_format',
        'update_time_format',
    ];

    public function getCreateTimeFormatAttribute()
    {
        return Carbon::parse($this->create_time)->toDateTimeString();
    }

    public function getUpdateTimeFormatAttribute()
    {
        return Carbon::parse($this->update_time)->toDateTimeString();
    }

    public function scopeByBusinessId($query, $id)
    {
        return $query->where('business_id', $id);
    }

    public function scopeByBusinessType($query, $type)
    {
        return $query->where('business_type', $type);
    }
}